home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / canvasgesture_rulermove.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-10-14  |  3.0 KB  |  99 lines

  1. /*
  2.  For general Scribus (>=1.3.2) copyright and licensing information please refer
  3.  to the COPYING file provided with the program. Following this notice may exist
  4.  a copyright and/or license notice that predates the release of Scribus 1.3.2
  5.  for which a new license (GPL+exception) is in place.
  6.  */
  7. /***************************************************************************
  8. *                                                                         *
  9. *   This program is free software; you can redistribute it and/or modify  *
  10. *   it under the terms of the GNU General Public License as published by  *
  11. *   the Free Software Foundation; either version 2 of the License, or     *
  12. *   (at your option) any later version.                                   *
  13. *                                                                         *
  14. ***************************************************************************/
  15.  
  16.  
  17.  
  18. #ifndef CANVAS_GESTURE_RULERMOVE_H
  19. #define CANVAS_GESTURE_RULERMOVE_H
  20.  
  21. #include <QPoint>
  22.  
  23. #include "scribusapi.h"
  24. #include "canvas.h"
  25. #include "canvasgesture.h"
  26. #include "canvasmode.h"
  27. #include "scribusview.h"
  28.  
  29. class QCursor;
  30. class QDragEnterEvent;
  31. class QDragMoveEvent;
  32. class QDragLeaveEvent;
  33. class QDropEvent;
  34. class QEvent;
  35. class QInputMethodEvent;
  36. class QMouseEvent;
  37. class QKeyEvent;
  38. class QPainter;
  39. class ScribusMainWindow;
  40.  
  41. /**
  42.   This class realizes the moving of guides and the moving of the ruler origin
  43.  */
  44. class SCRIBUS_API RulerGesture : public CanvasGesture
  45. {
  46.     Q_OBJECT
  47. public:
  48.     enum Mode { HORIZONTAL, VERTICAL, ORIGIN };
  49.     RulerGesture (ScribusView* view, Mode mode) : 
  50.         CanvasGesture(view), m_ScMW(m_view->m_ScMW), m_mode(mode), m_haveGuide(false), m_haveCursor(false), m_xy(0,0) {};
  51.  
  52.     /**
  53.         Prepares the gesture for 'mode' without using an existing guide. If 'mode' is HORIZONTAL
  54.         or VERTICAL, a new guide will be created when the mouse is moved over a page.
  55.      */
  56.     void prepare(Mode mode);
  57.     void clear();
  58.     
  59.     virtual void drawControls(QPainter* p);
  60.     virtual void activate(bool);
  61.     virtual void deactivate(bool);
  62.     virtual void mouseReleaseEvent(QMouseEvent *m);
  63.     virtual void mouseMoveEvent(QMouseEvent *m);
  64.     /**
  65.       This method should be called when the mousebutton is pressed.
  66.       If there's a moveable guide near this position, it prepares the gesture for moving this guide.
  67.      */
  68.     virtual void mousePressEvent(QMouseEvent *m);
  69.     
  70.     Mode getMode() { return m_mode; }
  71.     /**
  72.         Use this to test if there's a moveable guide near this position.
  73.         It prepares the gesture for moving this guide.
  74.      */
  75.     bool mouseHitsGuide(FPoint mousePointDoc);
  76.     /**
  77.       It tests for a guide near position, that guide being moveable or not.
  78.       If the test results in success, emits guideInfo;
  79.     */
  80.     void mouseSelectGuide(QMouseEvent *m);
  81. private:
  82.     ScribusMainWindow* m_ScMW;
  83.     Mode m_mode;
  84.     bool m_haveGuide;
  85.     int m_page;
  86.     double m_guide;
  87.     double m_currentGuide;
  88.     bool m_haveCursor;
  89.     QCursor m_cursor;
  90.     QPoint m_xy;
  91.     void movePoint(QMouseEvent *m, bool mouseRelease);
  92.     
  93.     signals:
  94.         void guideInfo(int /*direction*/, qreal /*position*/);
  95. };
  96.  
  97.  
  98. #endif
  99.